package cn.fengzhilun.javase.day12;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

import org.junit.Test;

import cn.fengzhilun.javase.day10.ex.Student;

public class TestList {
	@Test
	public void test1() {
		String s="fengzhilun";
//		for(int i:s) {
//			
//		}
		for(int i=0;i<s.length();i++) {
			System.out.println(s.charAt(i));
		}
		String s1= String.format("我是有%d元，可以买%s", 100,"fan");
		System.out.println(s1);
		System.out.printf("我是有%d元，可以买%s", 100,"fan");
	}  
	
	@Test
	public void test2() {
		//OutterClass out= new OutterClass();
		
		///InnerClass in= out.new InnerClass();
		
		//InnerClass in= new InnerClass();
		
		
	}
	
	@Test
	public void test3() {
		List<String> list =new ArrayList<String>();
		
		list.add("张三");
		list.add("李四");
		list.add("王五");
		
		
		System.out.println(list.size());
		
		System.out.println(list);
		System.out.println(list.get(2));
		System.out.println(list.remove("张三"));
		System.out.println(list);
		
		list.add(0, "赵六");
		System.out.println(list);
		System.out.println(list.contains("赵六"));
		//第一种
		for(int i=0;i<list.size();i++) {
			
			System.out.println(list.get(i));
		}
		//第二种
		for(String i:list) {
			
			System.out.println(i);
		}
		//第三种
		Iterator<String> itr= list.iterator();
		while(itr.hasNext()) {
			System.out.println(itr.next());
			
		}
		
		List<String> list2 = Arrays.asList("王五","赵六","赵四");
		
		Collections.sort(list2);
		
		System.out.println(list2);
		System.out.println("********");
		List<Student> list3= Arrays.asList(
				new Student("张三",18),
				new Student("李四",25),
				new Student("王五",20)
				
				);
//		list3.sort(new Comparator<Student>() {
//
//			@Override
//			public int compare(Student o1, Student o2) {
//				return o1.getAge()-o2.getAge();
//			}
//
//			
//		});
//		System.out.println(list3);
		
		Collections.sort(list3);
		System.out.println(list3);
	}
	
	
}
